import re

with open('network.txt', 'a', encoding='utf-8') as sys_file:

    with open('test.log', 'r', encoding='utf-8') as f:
        for line in f.readlines():
            if re.search('bms start output:', line, re.IGNORECASE) or re.search('bms stop output:', line, re.IGNORECASE):
                print(line)
                sys_file.write(line)




